<?php
include_once('admin/structures/tableEditors.php');
include_once('admin/structures/editorFields.php');

class adminChampionships extends simpleTableEditor
{
    //construct games object
    function adminChampionships()
    {
        global $lang;

        $this->simpleTableEditor(CHAMPIONSHIPS_TABLE, 'championships', 'Championships',  $lang['AdminEditChampionshipsInfo'], true, true);
        $this->addColumn(new fieldId('c_id'));
        $this->addColumn(new fieldTitle($lang['ChampionshipName'],'c_title','',100));
        $this->addColumn(new fieldText($lang['ChampionshipShortName'],'c_smallTitle','',5));
        $this->addColumn(new fieldLongText($lang['ChampionshipIntroText'],'c_introText','',8));
        $this->addColumn(new fieldLongText($lang['ChampionshipScoringText'],'c_scoringText','',8));
        $this->addColumn(new fieldLongText($lang['ChampionshipMeetingText'],'c_meetingText','',8));
        $this->addColumn(new fieldLongText($lang['ChampionshipRulesText'],'c_rules','',8));
        $this->addColumn(new fieldNumeric($lang['ChampionshipEventsPerMeeting'],'c_eventsPerMeeting','',1,10));
        $this->addColumn(new fieldText($lang['ChampionshipHandbookURL'],'c_handbookURL','',255));
        $this->addColumn(new fieldText($lang['ChampionshipBroadcastLiveURL'],'c_broadcastLiveURL','',255));
        $this->addColumn(new fieldText($lang['ChampionshipBroadcastDownloadURL'],'c_broadcastDownloadURL','',255));
        $this->addColumn(new fieldText($lang['ChampionshipModDownloadURL'],'c_broadcastDownloadURL','',255));
        $this->addColumn(new fieldText($lang['ChampionshipRFM'],'c_rfm','',50));
        $this->addColumn(new fieldYesNoComboBox($lang['StagedEvents'],'c_stagedEvents',''));
        $this->addColumn(new fieldYesNoComboBox($lang['ChampionshipActive'],'c_active',''));
        $this->addColumn(new fieldYesNoComboBox($lang['ChampionshipSignUpsOpen'],'c_openSignUps',''));
        $this->addColumn(new fieldYesNoComboBox($lang['ChampionshipCarNumbers'],'c_carNumbers',''));
        $this->addColumn(new fieldYesNoComboBox($lang['ChampionshipCarChanging'],'c_carChanging',''));
        $this->addColumn(new fieldYesNoComboBox($lang['ChampionshipClassChanging'],'c_classChange',''));
        $this->addColumn(new fieldNumeric($lang['ChampionshipDriversPerTeam'],'c_driversPerTeam','',0,10));
        $this->addColumn(new fieldNumeric($lang['ChampionshipMinRacesToEnter'],'c_minRacesToEnter','',0,100));
        $this->addColumn(new fieldNumeric($lang['ChampionshipMultiDriverEntryMin'],'c_multiDriverEntryMin','',0,10));
        $this->addColumn(new fieldNumeric($lang['ChampionshipMultiDriverEntryMax'],'c_multiDriverEntryMax','',0,10));
        $this->addColumn(new fieldYesNoComboBox($lang['ChampionshipOneMakePerTeam'],'c_multipleCarsPerTeam',''));
        $this->addColumn(new fieldSimpleComboBox($lang['ChampionshipTeamChanging'],'c_teamChanging','',
                Array(0 => $lang['ChampionshipTeamChangingOpt0'],
                      1 => $lang['ChampionshipTeamChangingOpt1'],
                      2 => $lang['ChampionshipTeamChangingOpt2'])));
        $this->addColumn(new fieldYesNoComboBox($lang['ChampionshipIncidents'],'c_incidents',''));
        $this->addColumn(new fieldRecordQueryComboBox($lang['ChampionshipDefaultDivision'],'c_defaultDiv','',
                'SELECT d_id, d_title FROM ' . DIVISIONS_TABLE . ' WHERE d_champid = %1$s ORDER BY d_order ASC', 'd_id', 'd_title',
                true, 0, $lang['Unassigned']));
        $this->addColumn(new fieldText($lang['ServerPassword'],'c_serverPassword','',16));
        $this->addColumn(new fieldYesNoComboBox(sprintf($lang['ChampionshipHasTitle'],$lang['Drivers']),'c_hasDriverTitles',sprintf($lang['ChampionshipHasTitleInfo'],$lang['Drivers'])));
        $this->addColumn(new fieldYesNoComboBox(sprintf($lang['ChampionshipHasTitle'],$lang['Teams']),'c_hasTeamTitles',sprintf($lang['ChampionshipHasTitleInfo'],$lang['Teams'])));
        $this->addColumn(new fieldYesNoComboBox(sprintf($lang['ChampionshipHasTitle'],$lang['Manufacturers']),'c_hasManufacturerTitles',sprintf($lang['ChampionshipHasTitleInfo'],$lang['Manufacturers'])));
        $this->addColumn(new fieldTableQueryComboBox($lang['ChampionshipLicense'],'c_license','','SELECT l_id, l_name FROM ' . LICENSES_TABLE . ' ORDER BY l_order ASC', 'l_id', 'l_name'));
        $this->addColumn(new fieldTableQueryComboBox($lang['Game'],'c_game','','SELECT g_id, g_name FROM ' . GAMES_TABLE . ' ORDER BY g_name ASC', 'g_id', 'g_name'));
        $this->addColumn(new fieldTableQueryComboBox($lang['Series'],'c_series','','SELECT s_id, s_title FROM ' . SERIES_TABLE . ' ORDER BY s_title ASC', 's_id', 's_title',
                                    true, 0, $lang['None']));
        $logoThmb = new fieldDummy('c_logoThmbURL');
        $this->addColumn(new fieldImage($lang['Logo'],'c_logoURL','','champ',200,150, false, true, $logoThmb, 80, 60));
        $this->addColumn($logoThmb);
        $this->doStuff();

    }

    //Overwrite Selection Function
    protected function getSelectionOptions()
    {
        return array("query" => 
            "SELECT c_id, c_title, g_name
             FROM " . CHAMPIONSHIPS_TABLE . ", " . GAMES_TABLE . "
             WHERE c_game = g_id ORDER BY c_title ASC",
            "id" => "c_id", "text" => "c_title", "minor" => "g_name");
    }
}
?>
